package com.book.system.dao;

import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Map;

@Slf4j
public class BookDao {
    public List<Map<String,Object>> list(String name, Integer classId){

        //创建临时sql
        StringBuffer tempSql = new StringBuffer("select * from book_info where 1=1");
        if (name != null && "".equals((name))) {
            tempSql.append(" and name like '%")
                    .append(name)
                    .append("%'");

        }
        if (classId != null && classId !=0) {
            tempSql.append("and class_id= ")
                    .append(classId);

        }
        String sql = tempSql.toString();

        log.info("sql语句为：{}",sql);

        List<Map<String, Object>> list = BaseDao.executeQuery(sql);


        return list;

    }
}
